package com.stwyj.sbd.dao.repository.custom.impl;

import com.stwyj.sbd.dao.repository.custom.UserRepositoryCustom;
import com.stwyj.sbd.entity.domain.UserCollection;
import org.springframework.data.mongodb.core.MongoTemplate;

import javax.annotation.Resource;

import static org.springframework.data.mongodb.core.query.Criteria.where;
import static org.springframework.data.mongodb.core.query.Query.query;

/**
 *<p>
 * userRepository 自定义方法实现
 *</p>
 *
 * @author stwyj
 * @since 2018/12/3
 */
public class UserRepositoryImpl implements UserRepositoryCustom {

    @Resource
    private MongoTemplate mongoTemplate;

    /**
     * 根据id查询一条记录手写实现
     *
     * @param id id
     * @return user记录
     */
    @Override
    public UserCollection findOneUserCollectionById(String id) {
        return mongoTemplate.findOne(query(where("id").is(id)), UserCollection.class);
    }
}
